package com.unionpay.upyzt.example;

import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.model.Media;
import com.unionpay.upyzt.resp.MediaResp;

import java.io.File;

public class MediaExample {

    /**
     * 运行 Demos
     *
     * @return 媒体ID
     */
    public static String runDemos() throws UpyztException {
        MediaExample mediaExample = new MediaExample();

        // 上传图片
        MediaResp mediaResp = mediaExample.uploadImage();

        return mediaResp.getMediaId();
    }

    /**
     * 上传图片
     *
     * @return 返回参数
     */
    public MediaResp uploadImage() throws UpyztException {
        File file = new File(Main.getResPath("id_card_sample.jpg"));
        System.out.println("------- 上传图片 -------");
        MediaResp resp = Media.uploadImage(file);
        System.out.println(resp);
        return resp;
    }

}
